#coding=gbk
if __name__ == '__main__':
    print ("line filter")
    folder=r"c:/log/"
    key = 'cp4q'
    in_filename = r'C:/PIInterfaceService201401278.log'
    out_filename = r'c:/new.txt'
    in_file = open(in_filename, 'r')
    out_file = open(out_filename, 'w')
    for line in in_file:
        if line.find(key)!=-1 :
            print (line[:-1])
            out_file.write(line)
    
    print ('end')

            